'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 副本记录
 * @author sundbcn@gmail.com (sun debing)
 */

var mongoConnector = require('../libs/mongodb/mongoConnector');
/* jshint unused:false */
var payRecordSchema = require('../schemas/payRecordSchema');
var PayRecord = mongoConnector().model('PayRecord');

/**
 * 添加一个支付记录
 */
module.exports.addOrder = function (order_id, role_id, product_id, amount, cb) {
    // 创建成功后
    function afterCreate(err, model) {
        cb(err, model);
    }

    PayRecord.create({
        role_id: role_id,
        order_id: order_id,
        product_id: product_id,
        amount: amount
    }, afterCreate);
};

/**
 * 获取订单
 * @param  {[type]}   order_id [description]
 * @param  {Function} cb       [description]
 * @return {[type]}            [description]
 */
module.exports.getOrder = function (order_id, cb) {
    PayRecord.findOne({
        order_id: order_id
    }, cb);
};
